const oss = require('../../services/ossService');
const tokens = require('../../services/tokenService');
const wechatController = require('../../controllers/wechat');

module.exports = app => {
  var express = require('express');
  var router = express.Router();

  router.post('/bind', wechatController.bind);
  router.post('/token', wechatController.openid_exist);
  router.get('/info', wechatController.info);

  router.all('*',function (req,res,next) {
    tokens.checkToken(req.header('s-token'), function (err,decode) {
      if (err)
        return res.send({code: 50014, message: '身份校验失败'});
      req.decode = decode;
      next()
    })
  });


  app.use('/wechat', router);
};
